package beanstao.util.store.domainobject;

import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import beanstao.util.interfaces.to.IToJson;
import beanstao.util.json.JsonLib;

import com.google.common.collect.Lists;

public class DomainList<T> implements List<T>, Serializable, IToJson
{

	// +++++++++ List接口的实现 ++++++++++++++++++++++++++

	private static final long serialVersionUID = -8150018591909475302L;

	private final List<T> _DomainList = Lists.newArrayList();

	@Override
	public boolean add(final T e)
	{
		return this._DomainList.add(e);
	}

	@Override
	public void add(final int index, final T element)
	{
		this._DomainList.add(index, element);
	}

	@Override
	public boolean addAll(final Collection<? extends T> c)
	{
		return this._DomainList.addAll(c);
	}

	@Override
	public boolean addAll(final int index, final Collection<? extends T> c)
	{
		return this._DomainList.addAll(index, c);
	}

	@Override
	public void clear()
	{
		this._DomainList.clear();
	}

	@Override
	public boolean contains(final Object o)
	{
		return this._DomainList.contains(o);
	}

	@Override
	public boolean containsAll(final Collection<?> c)
	{
		return this._DomainList.containsAll(c);
	}

	@Override
	public T get(final int index)
	{
		return this._DomainList.get(index);
	}

	@Override
	public int indexOf(final Object o)
	{
		return this._DomainList.indexOf(o);
	}

	@Override
	public boolean isEmpty()
	{
		return this._DomainList.isEmpty();
	}

	@Override
	public Iterator<T> iterator()
	{
		return this._DomainList.iterator();
	}

	@Override
	public int lastIndexOf(final Object o)
	{
		return this._DomainList.lastIndexOf(o);
	}

	@Override
	public ListIterator<T> listIterator()
	{
		return this._DomainList.listIterator();
	}

	@Override
	public ListIterator<T> listIterator(final int index)
	{
		return this._DomainList.listIterator(index);
	}

	@Override
	public boolean remove(final Object o)
	{
		return this._DomainList.remove(o);
	}

	@Override
	public T remove(final int index)
	{
		return this._DomainList.remove(index);
	}

	@Override
	public boolean removeAll(final Collection<?> c)
	{
		return this._DomainList.removeAll(c);
	}

	@Override
	public boolean retainAll(final Collection<?> c)
	{
		return this._DomainList.retainAll(c);
	}

	@Override
	public T set(final int index, final T element)
	{
		return this._DomainList.set(index, element);
	}

	@Override
	public int size()
	{
		return this._DomainList.size();
	}

	@Override
	public List<T> subList(final int fromIndex, final int toIndex)
	{
		return this._DomainList.subList(fromIndex, toIndex);
	}

	@Override
	public Object[] toArray()
	{
		return this._DomainList.toArray();
	}

	@SuppressWarnings("hiding")
	@Override
	public <T> T[] toArray(final T[] a)
	{
		return this._DomainList.toArray(a);
	}

	public String toJson()
	{
		return JsonLib.fromObject(this._DomainList);
	}

}
